﻿/*
排列学生成绩 
Time Limit:1000MS  Memory Limit:32768K


Description:
一些向量数据，表示许多学生的各门成绩。编程，从中挑出平均分数在60分以上的学生进行排序输出。

Sample Input:
Zhangsan 90 85 77 25 63
Lisi      58 73 66 85 90
Wangwu   70 80 90 51 52
Qianliu  80 63 58 52 50
Chenqi   90 28 38 48 58
Zhouba   40 70 70 33 55

Sample Output:
1 Lisi
2 Wangwu
3 Zhangsan

*/


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

bool compare(pair<string, double> & stud1, pair<string, double> & stud2)
{
	return stud1.second > stud2.second;
}
int main()
{
	string name;
	int credits[5];

	vector< pair<string, double> > students;
	students.reserve(10);
	while (cin>>name>>credits[0]>>credits[1]>>credits[2]>>credits[3]>>credits[4])
	{
		double average = accumulate(credits, credits+5, 0.0)/5.0;
		if((int)average>60)
		{
			pair<string, double> student = make_pair(name, average);
			students.push_back(student);
		}
	}
	sort(students.begin(), students.end(), compare);

	for (int i=0; i<students.size(); ++i)
	{
		cout<<(i+1)<<" "<<students[i].first<<endl;
	}
	return 0;
}



/*
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_ELEMS 128
#define MAX_CHARS 32

int comparator(const void *pa, const void *pb)
{
	return strcmp(*(char* const*)pa, *(char* const*)pb);

}
int main(int argc, char* argv[])
{
	char *p[MAX_ELEMS];
	char names[MAX_ELEMS][MAX_CHARS];
	unsigned i=0u, k=0u;
	char credits[MAX_CHARS];
	unsigned score[5];
	unsigned sum;
	while (EOF!=scanf("%s%u%u%u%u%u", name , score, score+1,score+2,score+3,score+4) &&i!=3)
	{
		sum=score[0]+score[1]+score[2]+score[3]+score[4];
		if(sum>300u)
		{
			strcpy(names[i], name);
			p[i]=names[i];
			++i;
		}
	}
	qsort(p, i, sizeof(char*), comparator);

	for (k=0; k<i; ++k)
	{
		printf("%u:%s\n", k+1, names[k]);
	}
	return 0;
}
*/